CoolMenus
CoolMenu unit

 Version 1.09  14-May-97

__________________________________________________________________________________

The CoolMenu unit contains the declarations of TMenuItemAdditionalInfo, TMenuItemEvenMoreInfo, TMenuEvenMoreInfo and TCoolMenuForm and their associated objects, types, and routines.

When you add a component declared in this unit to a form, the unit is automatically added to the uses clause of that form's unit.

The following items are declared in the Menus unit:

Components

TMenuItemAdditionalInfo

TMenuItemEvenMoreInfo

TMenuEvenMoreInfo

TCoolMenuForm

Types

TMsgOccurs

TRefreshAction

TRefreshEvent

TSizes

TTextAlign

TMenuOption

TMenuOptions

Exceptions

ECoolMenuError

Constants

crCool

Additional information

More about the components

Update from previous versions

Release history

Copyright

Shareware

Contact the Author


TMenuItemAdditionalInfo

  TMenuItemAdditionalInfo component

__________________________________________________________________________________

See also

TMenuItemEvenMoreInfo

More about the components

Properties

Font

Picture

TrColor

SelColor

NormColor

TextAlign

Options

OwnerMenu

CustomImgSize

Methods

DrawItem

MeasureItem

Unit

CoolMenus

Description

This component written for use with TMenuItem component. TMenuItemAdditionalInfo holds additional information about  TMenuItem. It is Font  and Picture to draw menu item.

You can use any available font (any style, color, size). Any icon (size not important, it can be 32x32 as well as 16x16), Bitmap or Metafile. Actually, this component is only basic class for TMenuItemEvenMoreInfo one, but for those of you who likes Windows API I have declared it as public. ;-) Of course better idea is to use TMenuItemEvenMoreInfo component because I did there all the job instead of you.

Anyhow TMenuItemAdditionalInfo is all you need to create cool menus if you feel ok to add some (a lot of) code to your form yourself. Just add one such component to your form (you can add as much as you need though). See Example1 from CoolMenus package to see how it works.


Font
Font property

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

property Font: TFont;

Font property points to Font to use in modified menu item.


Icon
Picture property

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

property Picture: TPicture;

Picture property points to picture to use with modified menu item. It can be TIcon,  TBitmap or TMetafile. Pictures size depends from fonts size. Enjoy.

You can specify transparent color for Bitmap using TransparentColor property.


TransparentColor
TrColor property

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

property TrColor: TColor;

If Picture contains bitmap (and Icon in 16 bit version) you can specify transparent color for this bitmap. Icons in 32 bit version and metafiles has own transparent color.


SelColor
SelColor property

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

property SelColor: TColor;

Color of menu item when its selected. The default value is clHighlight - your systems default  selected menu items color. See Example 2.


NormColor
NormColor property

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

property NormColor: TColor;

Color of menu item when its not selected. The default value is clMenu - your systems default menus color. See Example 2.


TextAlign
TextAlign property

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

property  TextAlign: TTextAlign;

Value                             Meaning

alRght                             Text in the right of the picture (default).

AlLeft                             Text in the left of the picture.

alTop                              Text above the picture.

alBottom                         Text below the picture.


Options
Options property

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

property Options: TMenuOptions

Value                                           Meaning

omAlwaysDefFont                    Always use default font for menu item.

                                                      This way you wont  be able to use custom fonts.

omAlwaysDefFontColor          Always use default color for menu items text.

                                                      You can use any font but color always will be default.

                                                       (To not to worry about the schemes ;-).

omFixedImgSize                         Fixed (16x16) image size. Otherwise the image size

                                                      depends from fonts size. You may want to set it to True

                                                       for national fonts or if you use small size fonts.

omDrawBarIfNeeded                 Until its True item wont paint vertical bar even if you

                                                      have added one.

omPaintWallpaper                     Until its true item wont paint the wallpaper even if you have

                                                       specified one.

omPaintSelWallpaper,                Until its true selected item wont paint the wallpaper even if you have

                                                       specified one.

omTileWallpaper                        If WallPaper is specified points to the way to paint wallpaper

                                                       Center (default) or tile.

omTileSelWallpaper                   If SelWallPaper points to the way to paint wallpaper

                                                       Center (default) or tile.


OwnerMenu
OwnerMenu property

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

property OwnerMenu:  TMenuEvenMoreInfo;

Run-time and read-only. Points to  TMenuEvenMoreInfo component (if available).


CustomImgSize
CustomImgSize property

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

property CustomImgSize: Integer;

When omFixedImgSize is in Options you can specify fixed size for images using CustomImgSize, otherwise images size depends on font size. By default CustomImgSize is 16 (16x16).


DrawItem
DrawItem mehod

See also

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

procedure DrawItem(Msg: TWMDrawItem; ACaption: string);

This method should be called from your forms WM_DRAWITEM message handler. ACaption  is a caption of TMenuItem you are going to modify. See examples for more information.


MeasureItem
MeasureItem mehod

See also

__________________________________________________________________________________

Applies to TMenuItemAdditionalInfo , TMenuItemEvenMoreInfo  components

Declaration

procedure MeasureItem(Msg: TWMMeasureItem; ACaption: string);

This method should be called from your forms WM_MEASUREITEM message handler. ACaption  is a caption of TMenuItem you are going to modify. See examples for more information.


TMenuItemEvenMoreInfo

  TMenuItemEvenMoreInfo component

__________________________________________________________________________________

See also

TMenuEvenMoreInfo

More about the components

Properties

Menu

MenuItem

Font

Picture

TrColor

SelColor

NormColor

TextAlign

Options

OwnerMenu

CustomImgSize

Methods

DrawItem

MeasureItem

Unit

CoolMenus

Description

This component is descendant of TMenuItemAdditionalInfo component. As its parent, this component holds additional information  for TMenuItem but there are some important distinctions between them:

Unlike TMenuItemAdditionalInfo this component has been written for use with TMenuEvenMoreInfo

component. (Like TMenuItem and TMenu).

Unlike situation with TMenuItemAdditionalInfo (when its enough to add only one TMenuItemAdditionalInfo component to your form) you need to add as much TMenuItemEvenMoreInfo components  as many menu items you wish to modify.

Unlike TMenuItemAdditionalInfo this component in pair with TMenuEvenMoreInfo supports:

  - Hot keys (with & prefix).

  - ShortCuts (Accelerators)

  - TMenuItems Checked property.  (Draws appropriate picture).

You need not to write even one string of code here! ;-)

Please read TMenuEvenMoreInfo components description. See Example2/Example3/Example4 to learn how TMenuItemEvenMoreInfo works.


Menu
Menu property

__________________________________________________________________________________

Applies to MenuItemEvenMoreInfo  components

Declaration

property Menu: TMenu;

Menu property points to TMenu descendant (TMainMenu, TPopupMenu and so on) with TMenuItem you wish to modify.


MenuItem
MenuItem property

__________________________________________________________________________________

Applies to MenuItemEvenMoreInfo  components

Declaration

property MenuItem: TMenuItem;

MenuItem property points to TMenuItem component you wish to modify. Please note that if you use more than one menu, TMenuItem specified in MenuItem property have to be one of  specified in Menu property menu items.


TMenuEvnMoreInfo component

  TMenuEvenMoreInfo component

__________________________________________________________________________________

See also

More about the components

Properties

Items

WallPaper

SelWallPaper

BarBitmap

Methods

Refresh

AddBar

RemoveBar

GlobalSetParameters

Unit

CoolMenus

Description

There are no published properties declared here. You need  to add one this component to the form if you plan to use TMenuItemEvenMoreInfo component(s).

Two rules here:

Add to your form as much TMenuItemEvenMoreInfo components as many menu items you going to modify. Each TMenuItemEvenMoreInfo component holds information about one TMenuItem component. And add only one (but one) TMenuEvenMoreInfo component.

Change your form's ancestor to TCoolMenuForm.  An example:

        Change:

           Form1 = class  (TForm)

        To:

           Form 1 = class  (TCoolMenuForm)

Note: You need not to do it with TMenuItemAdditionalInfo.


Items
Items property

__________________________________________________________________________________

Applies to TMenuEvenMoreInfo  component

Declaration

property  Items: TList;

Run-time only. Points to the list of all TMenuItemEvenMoreInfo items you have created.


WallPaper
WallPaper property

__________________________________________________________________________________

Applies to TMenuEvenMoreInfo  component

Declaration

property  WallPaper: TBitmap;

The wallpaper to use with menu item. See Options  for more info. Note: If  WallPaper is specified then value of NormColor property is no more important.


SelWallPaper
SelWallPaper property

__________________________________________________________________________________

Applies to TMenuEvenMoreInfo   component

Declaration

property  SelWallPaper: TBitmap;

The wallpaper to use with menu item when its selected. See Options  for more info. Note: If  SelWallPaper is specified then value of SelColor property is no more important


BarBitmap
BarBitmap property

__________________________________________________________________________________

Applies to TMenuEvenMoreInfo   component

Declaration

property  BarBitmap: TBitmap;

RunTime and read only. If you have added vertical bar with text you can get the bitmap (bar) using this property. See AddBar method.


Refresh
Refresh mehod

__________________________________________________________________________________

Applies to TMenuEvenMoreInfo  components

Declaration

procedure Refresh(Sender: TObject; Action: TRefreshAction);  virtual;

You can update modified menu items using this method.  It has to be done for example when you change properties of associated with TMenuEvenMoreInfo TMenuItem component. Generally you can control state of your modified items using RefreshMenu property of TCoolMenuForm. But if you want to do it directly set RefreshMenu  to RA_NONE and call this method.

Parameters

Action      Action to be performed.

       Value                             Meaning

        RA_NONE                    Nothing will happen. Procedure returns immediately.

        RA_REFRESH             Items will be repainted.

        RA_RESTORE             Items will be restored to their original state.


AddBar
AddBar mehod

See also

__________________________________________________________________________________

Applies to TMenuEvenMoreInfo  components

Declaration

procedure AddBar(ACaption: string; Size: Integer; Serif: Boolean; Space: Word;

                                                                              ABack, AFore: TColor; IsGradient: Boolean);

Adds vertical bar with text to menus.

Parameters

Paints vertical bar with text specified in the ACaption, with size Size using background color ABack and text color AFore Font can be vector or not (Serif).  The Space specifies space before text (from menus down). IsGradient specifies the method to paint bar (gradient or not). See Example 5.


RemoveBar
RemoveBar mehod

See also

__________________________________________________________________________________

Applies to TMenuEvenMoreInfo  components

Declaration

procedure RemoveBar;

Removes vertical bar with text from menus. Actually you may need not to call this method at all even if you have added the bar.


GlobalSetParameters
GlobalSetParameters method

__________________________________________________________________________________

Applies to TMenuEvenMoreInfo  components

Declaration

procedure GlobalSetParameters(AFont: TFont; AColor, ASelColor, ATrColor: TColor;

                                                   AAlign: TTextAlign; AOptions: TMenuOptions);

You may want to modify all assigned menu items. To do it call this method. Each parameter will be passed to the appropriate TMenuItemEvenMoreInfo components property.


TCoolMenuForm

__________________________________________________________________________________

More about the components

Properties

RefreshMenu

MenuCursor

Unit

CoolMenus

Description

If you want to know how this component works - register CoolMenus and get the sources. ;-)


RefreshMenu
RefreshMenu property

__________________________________________________________________________________

Applies to  TCoolMenuForm  component

Declaration

property RefreshMenu: TRefreshAction;

Action to be performed each time menu becomes active.

Value                             Meaning

        RA_NONE                    Nothing will happen. Procedure returns immediately.  (default)

        RA_REFRESH             Items will be repainted.

        RA_RESTORE             Items will be restored to their original state.

Note : If you do not plan to change properties of the modified menu items (TMenuItem components) you do not need to change  this property (it should be RA_NONE), otherwise change it in the way you need to. If you do plan to change properties of modified TMenuItem components  but not really often,

left  RefreshMenu RA_NONE and  call Refresh method of the TMenuEvenMoreInfo component after changing the properties (Caption, Enabled etc).


MenuCursor
MenuCursor property

__________________________________________________________________________________

Applies to  TCoolMenuForm  component

Declaration

property MenuCursor: TCursor;

Cursor to be used with menus (main, popup and system ones). Try crCool, you will like it.


Cursor resource.


Exception
ECoolMenuError exception

Exception for all the above components. Nothing special.


TMsgOccurs

TMsgOccurs = procedure (var Msg: TMessage) of object;


TRefreshAction

TRefreshAction = (RA_NONE, RA_REFRESH, RA_RESTORE);


TRefreshEvent

TRefreshEvent = procedure (Sender: TObject; Action: TRefreshAction) of object;


TSizes

PSizes = ^TSizes;

TSizes = record

    ImgLeft,

    ImgTop,

    TxtLeft,

    TxtTop,

    ImgTxtHeight,

    TxtWidth,

    mItemHeight,

    mItemWidth,

    Margin: Integer;

  end;


TTextAlign

TTextAlign = alTop..alRight;


TMenuOption

TMenuOption = (omAlwaysDefFont, omAlwaysDefFontColor,

                           omFixedImgSize, omDrawBarIfNeeded);


TMenuOptions

TMenuOptions = set of TMenuOption


Components
More about the components

Although you can use TMenuItemAdditionalInfo component to modify your menus and nothing also from this unit is required (although if you going to use wallpaper you need to add one TMenuEvenMoreInfo component anyway, see Example 1 / Example 3) but I suggest you to use TMenuItemEvenMoreInfo , TMenuEvenMoreInfo and TCoolMenuForm components. No additional code, more features and many other pluses. You can combine both methods. See Example3 from the package

Important note about the TPopupMenu. If you have modified menu items from TPopupMenu, do not call this menus Popup method, or AutoPopup property. Call directly  TrackPopupMenu API function. See Example1/Example3/Example4.

Also note that if you gonna use only TMenuItemAdditionalInfo component you need to handle WM_COMMAND for popup menu items yourself  (Example1). So once again - forget about the TMenuItemAdditionalInfos way.


Release history

Version 1.00 31-Mar-97

          Initial release.

Version 1.01 4-Apr-97

     + Now you can use Hot keys (with '&' prefix) in menu items modified with

         TMenuItemEvenMoreInfo  component.

Version 1.02 7-Apr-97

       + Now you can use Bitmaps (*.bmp) and Metafiles (*.wmf) as well

         (and of course Icons). Any size! For bitmaps you can specify

          transparent color.

       + Now you can use ShortCuts (Ctr+A etc).

       + Added resource file. Only one icon there wich becomes visible when

           menu item's checked property is True.

       + 16 bit version added.

  Version 1.03 9-Apr-97

       + Added RefreshMenu property to choose way of updating of

          modified items.

       + Fixed bug with handling of TMenuItem's Checked property

       + It's possible to choose cursor for menus now

       + Added cursor resource.

Version 1.04 14-Apr-97

       + Added  SelColor and  NormColor  properties of the

           TMenuItemAdditionalInfo component to set colors of menu items

       + Code optimized for better speed

Version 1.05 23-Apr-97

      + Added TextAlign property of TMenuItemAdditionalInfo  item to set the

          position of text relatively the picture.

      + Added WallPaper property of TMenuItemAdditionalInfo item to set the

          wallpapers for menu item. Try it out! ;-)

      + Added SelWallPaper property of TMenuItemAdditionalInfo item to set the

          wallpapers for menu item when it's selected.

Version 1.06a 23-Apr-97

       + Added AlwaysDefFont property of TMenuItemAdditionalInfo. If True then

          modified items will use always current font (color etc). It useful

           under Win32 when you changing the scheme. It wont work for Win16

          (there it will be always System font like it should be) NOTE: This

          way you wont be able to use custom fonts...

       * Fixed bug with popup menu item's OnClick event. (we were lost

          Sender ;-)

Version 1.07 29-Apr-97

       + AlwaysDefFont property replaced with Options one. More options are

          available!

       + Added vertical bar and all stuff (methods, propertied to support

           it). Can be gradient! Enjoy! :-)

       * Fixed bugs in resource file (32 bit) ! Replace old with new one!

Version 1.08 5-May-97

       + Now it's not necessary to modify each menu item in the popup

          menus.

       * Fixed few bugs with bar drawing, when it looked ugly and when it

          were impossible to use "throw menu" line (items with '-' caption)

       + Added two properties to AddBar method of the TMenuEvenMoreInfo

          component

       * Fixed (finally ;-) bug with check bitmap (if you were specified one

          you coldn't remove it by changing menu item's property Cheked to

          False, now you can)

       + Added options omTileWallpaper when True wallpaper will apply "tile"

          if False then you gonna use big bitmapas wallpaper for all the whole

          menu

       + The same for the SelWallpaper.

       + Added Items property (run-time only) to TMenuEvenMoreInfo to have

          access to all TMenuItemEvenMoreInfo components you have created.

       + You can now modify separators (menu items with '-' caption) you

          probably do not need to do it if you do not gonna modify background

          menu's color, but if you do, want to modify it or you gonna use

          wallpaper then modify '-' items.

       + Added GlobalSetParameters method to the TMenuEvenMoreInfo component.

       + OwnerMenu property TMenuItemAdditionalInfo read-only points to

          TMenuEvenMoreInfo component.

       + BarBitmap property of TMenuEvenMoreInfo holds the bar bitmap

          (if any).

Version 1.09 14-May-97

       * Fixed memory leak with painting of vertical bar (when you were used

          several bars).

       * Fixed memory leak in 16 bit version with icons painting.

       * Fixed bug when it were impossible to modify TCoolMenuForm's

          specific properties (RefreshMenu, MenuCursor) in OnCreate handler

       * Now paints separator line in the correct way no matter scheme (Win 95)

       * Added CustomImgSize property of the TMenuItemAdditionalInfo

          component to set up image's size (height and width both) when

          omFixedImgSize is true. Default 16 (16x16)


Copyright

The CoolMenus unit and everything that comes with it, is Copyright (C) 1997, by Artem A. Berman. All rights reserved.

Anything not explicitely allowed below, is not allowed.

You may distribute the unregistered version of CoolMenus freely, provided that all files are included and remain unmodified and that no extra files have been added to the package.

You may not ask any money for the distribution.

You may use the unregistered version of CoolMenus free of charge for testing purposes, but if you want to use it for other purposes than testing - you have to register it with the author.

Once you have registered, you will recieve a personal registered copy via email. This copy may not be copied or lend.

THIS SOFTWARE IS DISTRIBUTED "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE  OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. YOU USE IT AT YOUR OWN RISK. THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES,  LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.

You may not attempt to reverse compile, modify, translate or disassemble the software in whole or in part.


Sareware
Shareware

CoolMenus is being distributed as shareware. This means you can try it out for free, but if you like it you'll have to register it with the author.

The only difference between the unregistered and registered versions is that the registered one has not this (damn ;-) dialog box with remind to register.

There are two registration types: Registering with and without sources.

Registration without sources will cost you  $ US 10. You will receive a copy of CoolMenus  (both 16 bit and 32 bit versions) via email. You will have the opportunity to recieve updated versions for free via email.

Registration with sources will cost you  $ US 20. You will receive all the above plus sources.

Please Contact me  to learn how to register.


Update from previous versions

For Delphi 2.0 only! In version 1.05 I have changed the units name from CoolMenus to CoolMenu (I found for myself that its better to write {$IFDEF WIN32} each time when  needed than to write two units ;-). So remove first CoolMenus from componentss palette and then install CoolMenu.


Author
Contact the Author

Artem A. Berman

Ukraine

325000, Kherson

Kotovsky 4-10

art@aber.kherson.ua

art@ukrcom.kherson.ua

http://www.ukrcom.kherson.ua/art/

Im very interested in your feedback. Please report me about bugs (if youll find ones ;-). Your ideas and suggestions are welcome also! Please make sure you have the latest version of the CoolMenus. It always can be obtained (and many others  (mostly FREEWARE) components)  from the http://www.ukrcom.kherson.ua/art/delphi.html